/*
 * @Author: szx
 * @Date: 2021-10-29 11:55:08
 * @LastEditTime: 2021-10-29 12:30:25
 * @Description:
 * @FilePath: \leetcode\541\541.cpp
 */
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
class Solution {
   public:
    string reverseStr(string s, int k) {
        int n = s.length();
        for (int i = 0; i < n; i += 2 * k) {
            int l = i;
            int r = min(i + k - 1, n - 1);
            while (l < r) {
                swap(s[l++], s[r--]);
            }
        }
        return s;
    }
};
int main() {
    Solution s;
    cout << s.reverseStr("abcdefg", 2) << endl;

    return 0;
}
